/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.appcontext;

import java.util.Collection;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;

/**
 *
 * @author Administrator
 */
public class AppContext extends AbstractLookup {

    private final static InstanceContent content = new InstanceContent();
    private static AppContext lookup = new AppContext(content);

    private AppContext(InstanceContent content) {
        super(content);
    }

    public void add(Object instance) {
        content.add(instance);
    }

    public void remove(Object instance) {
        content.remove(instance);
    }

    public <T> void removeAll(Class<T> clazz) {
        Collection<? extends T> c = lookup.lookupAll(clazz);
        for (T t : c) {
            content.remove(t);
        }
    }

    public static AppContext getDefault() {
        return lookup;
    }
}
